package zelix.hack.hacks;

import net.minecraft.network.play.client.CPacketPlayer;
import zelix.hack.Hack;
import zelix.hack.HackCategory;
import zelix.utils.Wrapper;
import zelix.utils.system.Connection;
import zelix.utils.hooks.visual.ChatUtils;

import java.util.LinkedList;
import java.util.Queue;


public class Blink extends Hack {


	Queue<CPacketPlayer> packets = new LinkedList<>();
	boolean send = false;

	public Blink()
	{
		super("Blink", HackCategory.PLAYER);
		//this.setChinese(Core.Translate_CN[22]);
	}

	@Override
	public String getDescription() {
		return "Allows you to move without sending it to the server.";
	}

	@Override
	public boolean onPacket(Object packet, Connection.Side side) {
		if (side == Connection.Side.OUT && packet instanceof CPacketPlayer) {

			ChatUtils.message("Packets:" + String.valueOf(packets.size()));

			send = false;
			packets.add((CPacketPlayer) packet);
			return send;
		} else {
			send = true;
		}
		return send;
	}

	@Override
	public void onEnable() {
		if (Wrapper.INSTANCE.player() != null && Wrapper.INSTANCE.world() != null) {


		}
		super.onEnable();
	}

	@Override
	public void onDisable() {
		while (!packets.isEmpty())
			Wrapper.INSTANCE.sendPacket(packets.poll());


		super.onDisable();
	}
}
